<template>
    <el-dialog :visible.sync="visible" :close-on-click-modal="false" title="批量赋值" width="500px">
        <div style="font-size: 12px; color: #ff3333; margin-bottom: 20px">
            *复选以批量改变值，不勾选维持现有数据
        </div>

        <el-form :model="batchForm">
            <el-form-item label="要求时长">
                <div style="display: flex; align-items: center">
                    <el-checkbox v-model="batchForm.needLearnCk" style="margin-right: 20px" />
                    <second-set v-model="batchForm.needLearn" />
                </div>
            </el-form-item>

            <el-form-item label="学完积分">
                <el-checkbox v-model="batchForm.pointsCk" style="margin-right: 20px" />
                <el-input-number v-model="batchForm.points" size="mini" />
            </el-form-item>
        </el-form>

        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="confirmBatch()">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
import SecondSet from "@/components/SecondSet";

export default {
    name: "BatchOperationDialog",
    components: {
        SecondSet
    },
    props: {
        visible: {
            type: Boolean,
            default: false
        },
        dirList: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            batchForm: {
                needLearn: 0,
                needLearnCk: false,
                points: 0,
                pointsCk: false,
                faceStart: false,
                faceInterval: 0
            }
        };
    },
    methods: {
        confirmBatch() {
            // 创建更新对象的副本，以便向父组件发出事件
            const updateData = {
                needLearnCk: this.batchForm.needLearnCk,
                needLearn: this.batchForm.needLearn,
                pointsCk: this.batchForm.pointsCk,
                points: this.batchForm.points
            };

            this.$emit('batch-update', updateData);
            this.$emit('update:visible', false);
        }
    }
};
</script>
